<template>
  <!-- vue3页面 -->
    组件二：
    <div class="wrap">
        <h4>接收组件1传来的data1：<span style='color:#9c3939'>{{data1}}</span></h4>

        <el-button @click="two" type='primary'>发送true/false 给组件1</el-button>

    </div>
</template>

<script lang='ts'>
import { defineComponent, onMounted,onDeactivated, reactive ,ref, Ref,onActivated,inject} from 'vue'
import emitter from '@/utils/bus'
export default defineComponent({
  name: 'brotherFour',
  setup() {
    const data1 = ref()
    const data2 = ref(false)
    
    const two = ()=>{
        data2.value = !data2.value
        emitter.emit('data2',data2.value)
    }
    
    emitter.on('data1',(res)=>{
        data1.value = res
    })
    
    onActivated(()=>{
        // emitter.emit('data1',data1.value)
    })
    onDeactivated(() => {
    })
    return {
        two,
        data1,
        data2
    }
  }
})
</script>

<style scoped>

.wrap{
    border: solid;
    margin: 30px;
    height: 200px;
}
</style>